package com.example.yangyinzhaixian.AllActivity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.SeekBar;
import android.widget.TextView;
import com.example.yangyinzhaixian.R;
import com.example.yangyinzhaixian.common.PlayerManager;
import com.example.yangyinzhaixian.widget.media.IjkVideoView;
public class PlayActivity extends AppCompatActivity implements View.OnClickListener {
    private IjkVideoView Play_ijkVideo;
    private RelativeLayout activity_play;
    private PlayerManager playerManager;
    private Button Play_btn_start;
    private Button Play_btn_stop;
    private SeekBar seekbar_Play;
    private TextView play_now;
    private TextView play_stop;
    private LinearLayout play_liner1;
    private LinearLayout play_liner2;
    private Handler handler= new Handler(){
        @Override
        public void handleMessage(Message msg) {
            super.handleMessage(msg);
            switch (msg.what)
            {
                case 1:
                    play_liner1.setVisibility(View.GONE);
                    play_liner2.setVisibility(View.GONE);
                    break;
            }
        }
    };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_play);
        initView();
        Intent intent = getIntent();
        String videoUrl = intent.getStringExtra("videoUrl");
        playerManager = new PlayerManager(this);
        playerManager.play(videoUrl);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);//设置成全屏模式
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);//强制为横屏
        handler.sendEmptyMessageDelayed(1,3000);
    }
    private void initView() {
        Play_ijkVideo = (IjkVideoView) findViewById(R.id.Play_ijkVideo);
        activity_play = (RelativeLayout) findViewById(R.id.activity_play);
        Play_btn_start = (Button) findViewById(R.id.Play_btn_start);
        Play_btn_start.setOnClickListener(this);
        Play_btn_stop = (Button) findViewById(R.id.Play_btn_stop);
        Play_btn_stop.setOnClickListener(this);
        seekbar_Play = (SeekBar) findViewById(R.id.seekbar_Play);
        seekbar_Play.setOnClickListener(this);
        play_now = (TextView) findViewById(R.id.play_now);
        play_now.setOnClickListener(this);
        play_stop = (TextView) findViewById(R.id.play_stop);
        play_stop.setOnClickListener(this);
        play_liner1 = (LinearLayout) findViewById(R.id.play_liner1);
        play_liner1.setOnClickListener(this);
        play_liner2 = (LinearLayout) findViewById(R.id.play_liner2);
        play_liner2.setOnClickListener(this);
    }
    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.Play_btn_start:
                Play_btn_stop.setVisibility(View.VISIBLE);
                Play_btn_start.setVisibility(View.GONE);
                break;
            case R.id.Play_btn_stop:
                Play_btn_start.setVisibility(View.VISIBLE);
                Play_btn_stop.setVisibility(View.GONE);
                break;
        }
    }
}
